<?php
namespace app\exception;

class AppExceptionHandler
{
    public static function exception(\Exception $e)
    {
       while (ob_get_level())
       {
           ob_end_clean();
       }
       if (method_exists($e, 'getSeverity'))
       {
           //这是错误
           $errFacility = array_flip(array_slice(get_defined_constants(true)['Core'], 1, 15, true));
           $errType = '【' . $errFacility[$e->getSeverity()] . '】';
       }
       else 
       {
           $errType = '';
       }
       require 'AppExceptionView.php';
    }
    
    public static function error($errno, $errstr, $errfile, $errline, $context)
    {
//         var_dump(__METHOD__, func_get_args());
        throw new \ErrorException($errstr, $errno, $errno, $errfile, $errline);
    }
    
    public static function shutdown()
    {
        $e = error_get_last();
        if (!empty($e))
        {
//             var_dump($e);
            while (ob_get_level())
           {
               ob_end_clean();
           }
           require 'AppShutdownView.php';
        }
    }
    
}